<template>
  <div :class="className" :style="{height:height,width:width}" style="margin-top: -90px;" />
</template>

<script>
import echarts from 'echarts'
require('echarts/theme/macarons') // echarts theme
import resize from './mixins/resize'

export default {
  mixins: [resize],
  props: {
    className: {
      type: String,
      default: 'chart'
    },
    width: {
      type: String,
      default: '480px'
    },
    height: {
      type: String,
      default: '360px'
    }
  },
  data() {
    return {
      chart: null
    }
  },
  mounted() {
    this.$nextTick(() => {
      this.initChart()
    })
  },
  beforeDestroy() {
    if (!this.chart) {
      return
    }
    this.chart.dispose()
    this.chart = null
  },
  methods: {
    initChart() {
      this.chart = echarts.init(this.$el, 'macarons')

      this.chart.setOption({


         tooltip: {
            trigger: 'item'
          },
          legend: {
            top: '0%',
            left: 'center'
          },
          series: [
            {
              name: 'Access From',
              type: 'pie',
              radius: ['40%', '50%'],
              avoidLabelOverlap: false,
              label: {
                show: false,
                position: 'center'
              },
              emphasis: {
                label: {
                  show: true,
                  fontSize: 40,
                  fontWeight: 'bold'
                }
              },
              labelLine: {
                show: false
              },
              data: [
                { value: 10, name: '' },
                { value: 10, name: '' },
                { value: 10, name: '' },
                { value: 10, name: '' },
                { value: 10, name: '' },
                { value: 10, name: '' },

                { value: 10, name: '' },
                { value: 10, name: '' },
                { value: 10, name: '' },
                { value: 10, name: '' },
                { value: 10, name: '' },
                { value: 10, name: '' },
              ]
            }
          ]
      })
    }
  }
}
</script>
